package com.beijing.demo.find;

/**
 * 曹旭
 * 2025/4/23
 */
public class ArrayUtils {

    /**
     * 获取无序随机数组
     * @param len
     * @param value
     * @return
     */
    public static int[] getRanArray(int len,int value){
        int arrLen = (int)(Math.random() * (len + 1)); // [0,len]
        int[] arrs = new int[arrLen];
        for (int i = 0; i < arrs.length; i++) {
            arrs[i] = getRanValue(value); // [-value,value];
        }
        return arrs;
    }

    /**
     * 获取范围是[-value,value]之间的随机数
     * @param value
     * @return
     */
    public static int getRanValue(int value){
        return (int) (Math.random() * (value + 1)) - (int) (Math.random() * (value + 1));
    }

}
